//
//  PhoneBookTableCell.m
//  PhoneBook
//
//  Created by twicrow on 3/26/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PhoneBookTableCell.h"


@implementation PhoneBookTableCell

@synthesize name, address, phone;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code.
		
		name = [[UILabel alloc] init];
		name.textAlignment = UITextAlignmentLeft;
		name.font = [UIFont boldSystemFontOfSize:14.0f];
		
		address =[[UILabel alloc] init];
		address.textAlignment = UITextAlignmentLeft;
		address.font = [UIFont systemFontOfSize:11.0f];
		
		phone = [[UILabel alloc] init];
		phone.textAlignment = UITextAlignmentRight;
		phone.font = [UIFont boldSystemFontOfSize:11.0f];
		
		[self.contentView addSubview:name];
		[self.contentView addSubview:address];
		[self.contentView addSubview:phone];
		
    }
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state.
}

- (void)layoutSubviews {
	
	[super layoutSubviews];
	
	//CGRect contentRect = self.contentView.bounds;
	CGRect contentFrame = self.contentView.frame;
	CGFloat boundsX = 5.0f;
	
	CGRect frame;
	
	frame = CGRectMake(boundsX+0.0f, 0.0f, contentFrame.size.width, contentFrame.size.height*0.5);
	name.frame = frame;
	
	frame = CGRectMake(boundsX+0.0f, contentFrame.size.height*0.5, contentFrame.size.width, contentFrame.size.height*0.5);
	address.frame = frame;
	
	frame = CGRectMake(contentFrame.size.width*0.75-boundsX, contentFrame.size.height*0.5, contentFrame.size.width*0.25, contentFrame.size.height*0.5);
	phone.frame = frame;	
}


- (void)dealloc {
	
	[name release];
	[address release];
	[phone release];
	
    [super dealloc];
}


@end
